﻿CKEDITOR.dialog.add('actionbutton', function( editor ) {
        return {
                title:"按钮属性编辑",
                minWidth: 300,
                minHeight: 100,
                contents: [
                        {
                        id: 'info',
                        label: "与按钮绑定的动作",
                        elements: [
								{
				                    id: 'action',
				                    type: 'select',
									style:"width:280px",
				                    label: "与按钮绑定的动作",
				                    'default': '',
									items: window.formActions,
									setup:function(widget){
										var element=widget.element;
										var bindingfield=element.getAttribute("action");
										if(bindingfield){
											this.setValue(bindingfield);
										}
									},
				                    commit:function(widget){
										var element=this.getInputElement();
										var selectedIndex=element.$.selectedIndex;
										if(selectedIndex==-1){
											alert("请选择一个要绑定到当前按钮的动作.")
											return;
										}
										var count=element.getChildren().count();
										for ( var i = count-1; i>= 0; i--) {
											var ele=element.getChild(i);
					                        if (ele.$.selected){
					                        	var option=ele.$;
												widget.setData("action",option.value);
												widget.setData("text",option.text);
					                        }
						        		}
										
									}
								},
							{
			                    id: 'width',
			                    type: 'text',
								style:"width:280px",
			                    label: editor.lang.uflo.textfield.charWidth,
			                    'default': '90px',
								setup:function(widget){
									var element=widget.element;
									var styles=element.getAttribute("style");
									if(styles){
										var style=styles.split(";");
										for(var i=0;i<style.length;i++){
											var item=style[i].split(":");
											if(item[0]=="width"){
												this.setValue(item[1]);
												break;
											}
										}
									}
								},
			                    commit:function(widget){
									widget.setData("width",this.getValue());
								}  
			                }
                        ]
                }
                ]
        };
});